public class Solution {
    public char findTheDifference(String s, String t) {
        int[] counter = new int[26];
        for (char c: s.toCharArray()) {
            counter[c - 'a']++;
        }
        for (char c: t.toCharArray()) {
            if (--counter[c - 'a'] < 0) {
                return c;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        String s = "abcd";
        String t = "abcde";
        System.out.println(solution.findTheDifference(s,t));
    }
}
